package org.darcy.youchat.imageloader;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import org.darcy.youchat.YouChatApp;
import org.darcy.youchat.library.imagepicker.loader.YouChatImagePickerImageLoader;

import org.darcy.youchat.library.emoji.YouChatEmojiImageLoader;


/**
 * 仿微信图片选择控件需要用到的图片加载类
 */
public class MyImageLoader implements YouChatImagePickerImageLoader, YouChatEmojiImageLoader {

    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        RequestOptions options = new RequestOptions()
                .override(width, height);
        Glide.with(activity)
                .load(Uri.parse("file://" + path).toString())
                .apply(options)
                .into(imageView);
    }

    @Override
    public void loadEmoji(Context context, String path, ImageView imageView) {
        Glide.with(context)
                .load(Uri.parse("file://" + path).toString())
                .into(imageView);
    }

    public static void LoadNetImage(String imgUrl, ImageView imageView) {
        Glide.with(imageView)
                .load(imgUrl)
                .into(imageView);
    }

    public static void LoadLocalImage(String path, ImageView imageView) {
        Glide.with(imageView)
                .load(path)
                .into(imageView);
    }

}
